// *************************************************************************
//
//                                JOST
//
//               Copyright (C) 2007 by Angelo Corsaro.
//                       <angelo.corsaro@gmail.com>
//                          All Rights Reserved.
//
//   Permission to use, copy, modify, and distribute this software and
//   its  documentation for any purpose is hereby  granted without fee,
//   provided that the above copyright notice appear in all copies and
//   that both that copyright notice and this permission notice appear
//   in  supporting  documentation. I don't make  any  representations
//   about the  suitability  of this  software for any  purpose. It is
//   provided "as is" without express or implied warranty.
//
//
// *************************************************************************
//  
// *************************************************************************
#include <iostream>
#include <fstream>

#include <jost/jost.hpp>
#include <jost/Parser.hpp>

using namespace std;
#define MAX_FILE_SIZE 65536
int
main(int argc, char* argv[])
{
    if (argc < 2) {
        std::cout << "USAGE:\n\t"
                  << "jost <json-file>" << std::endl;
        exit(1);
    }

    ifstream ifile(argv[1], ifstream::in);
    
    jost::Object* o = 0;
    
    try {
        cout << "-------------------------\n";
        cout << "Parsed JSON Object:\n";
        o = jost::Parser::instance().parse(ifile);

        std::cout << o->serialize();
        cout << "\n-------------------------\n";
    }
    catch(const jost::MalformedJSONStream& e) {
        cout << "-------------------------\n";
        cout << "Parsing failed\n";
        std::cout << e.what() << std::endl;
        cout << "-------------------------\n";
    }

    delete o;

    return 0;
}


